package com.guaoran.restspringwebmvc.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

/**
 * @author : gucheng
 * @Description : <br/>
 *  可以通过扩展实现，无accept:application/xml时，默认为xml，通过修改集合列表
 *
 * @date :2018/11/12 16:00
 */
//@Configuration
public class MyWebMvcConfig implements WebMvcConfigurer {
    @Override
    public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
        converters.set(0,new MappingJackson2XmlHttpMessageConverter());
    }
}
